/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.prabhu.jeazyprops.props;

import com.prabhu.cmdwindow.ui.Display;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import javax.swing.JDialog;
import javax.swing.JPanel;

/**
 * Class for Displaying Options
 *
 * @author prabhu.p
 */
public class PropertyDisplayer extends Display {

    /**
     * Displays the Properties in a GUI for Editing and Updating
     */
    public void DisplaySettings(JPanel pJPanel) {
        JDialog lJDialog = null;
        lJDialog = new JDialog(lJDialog, Constants.get(Constants.ScreenTitleString));
        lJDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        lJDialog.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = gbc.gridy = 0;
        gbc.gridwidth = gbc.gridheight = 1;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.anchor = GridBagConstraints.NORTHWEST;
        gbc.weightx = gbc.weighty = 100;
        gbc.insets = new Insets(10, 10, 10, 10);
        lJDialog.add(pJPanel, gbc);
        lJDialog.setPreferredSize(pJPanel.getPreferredSize());
        lJDialog.setBounds(new Rectangle(pJPanel.getPreferredSize()));
//        lJDialog.setSize(pJPanel.getSize());
        lJDialog.setResizable(false);
        setWindowParameters(lJDialog);
        lJDialog.setVisible(true);
    }

    /**
     * Sets the window Position
     *
     * @param aThis The Widow container
     */
    private void setWindowParameters(Container aThis) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screenSize.width - aThis.getWidth()) / 2;
        int y = (screenSize.height - aThis.getHeight()) / 2;
        aThis.setBounds(x, y, aThis.getWidth(), aThis.getHeight());
    }

    /**
     * Print the Header for Properties
     */
    public void printPropertyHeader() {
        printHeader();
        printColumn(Constants.get(Constants.PrintTitleString));
        printHeader();
    }

    /**
     * Prints the Footer for Properties
     */
    public void printPropertyFooter() {
        printHeader();
        printColumn(Constants.get(Constants.PrintEndString));
        printHeader();
    }

    /**
     * Prints the Property
     */
    void printPropertyColumn(String Key, String Value) {
        printColumn(Key, Value);
    }
}
